<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('POS终端信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">SN号：</label>
                                <input type="text" name="branchPos.machineNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">商户编号：</label>
                                <input type="text" name="merno"/>
                            </li>
                            <li>
                                <label style="width: 100px;">渠道商户编号：</label>
                                <input type="text" name="ldMerno"/>
                            </li>
                            <li>
                                <label style="width: 100px;">终端状态：</label>
                                <select name="status" th:with="type=${@dict.getType('formal_status')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">终端类型：</label>
                                <select name="posType" th:with="type=${@dict.getType('terminal_type')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <a class="btn btn-primary single disabled" onclick="shutPos()" shiro:hasPermission="formalPos:formalPos:edit">
                    <i class="fa fa-edit"></i> 开启/关停终端
                </a>

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('formalPos:formalPos:edit')}]];
        var removeFlag = [[${@permission.hasPermi('formalPos:formalPos:remove')}]];
        var prefix = ctx + "formalPos/formalPos";
        var formalPosType = [[${@dict.getType('terminal_type')}]];
        var formalStatus = [[${@dict.getType('formal_status')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "POS终端信息",
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'posno',
                    title: 'POS编号'
                },
                {
                    field: 'branchPos.machineNum',
                    title: 'SN号'
                },
                {
                    field: 'posType',
                    title: '终端类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(formalPosType, value);
                    }
                },
                {
                    field: 'merno',
                    title: '商户编号'
                },
                {
                    field: 'ldMerno',
                    title: '渠道商户编号'
                },
                {
                    field: 'merchantInfo.merName',
                    title: '商户名称',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,3);
                    }
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentInfo.agentName',
                    title: '服务商名称',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,3);
                    }
                },
                {
                    field: 'status',
                    title: '终端状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(formalStatus, value);
                    }
                },

                {
                    field: 'isKcsim',
                    title: '抵扣状态',
                    formatter: function(value, row, index) {
                        if (''==value || undefined==value){
                            return '暂无';
                        }
                       if (0==value){
                           if ('A'==row.dqType){
                               return '无抵扣';
                           }else{
                               return '未抵扣';
                           }
                       }else{
                           return '已抵扣';
                       }
                    }
                },
                {
                    field: 'note',
                    title: '备注',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,3);
                    }
                },
                {
                    field: 'createman',
                    title: '操作人'
                },
                {
                    field: 'createdate',
                    title: '操作时间'
                }]
            };
            $.table.init(options);
        });

        function shutPos() {
            var id = $.table.selectColumns("id")
            if ($.common.isEmpty(id)) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.open("修改结算类型",prefix + "/shutPos/" + id,'800');
        }
    </script>
</body>
</html>